package com.codingke.codingbookstore.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.codingke.codingbookstore.App;
import com.codingke.codingbookstore.R;
import com.codingke.codingbookstore.adapter.base.ViewHolder;
import com.codingke.codingbookstore.utils.Constant;
import com.codingke.codingbookstore.utils.NumberUtils;
import com.codingke.codingbookstore.vo.Orders;

import java.util.ArrayList;

/**
 * descreption:
 * company: codingke.com
 * Created by vince on 15/12/1.
 */
public class SettlementOrderListItemAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<Orders> orderList;

    public SettlementOrderListItemAdapter(Context context,ArrayList<Orders> orderList){
        this.context = context;
        this.orderList = orderList;
    }
    @Override
    public int getCount() {
        return orderList.size();
    }

    @Override
    public Object getItem(int position) {
        return orderList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.settlement_order_list_item,null);
        }
        ImageView imageView2_bookImage = ViewHolder.getView(convertView,R.id.imageView2_bookImage,null);
        TextView textView5_bookname = ViewHolder.getView(convertView,R.id.textView5_bookname,null);
        TextView textView5_count_total = ViewHolder.getView(convertView,R.id.textView5_count_total,null);
        TextView textView6_discount_price = ViewHolder.getView(convertView,R.id.textView6_discount_price,null);

        Orders orders = orderList.get(position);
        textView5_bookname.setText(orders.getBookName());
        textView5_count_total.setText("x"+orders.getTotal());
        textView6_discount_price.setText(NumberUtils.format(orders.getDiscountPrice())+"元");
        App.bitmapUtils.display(imageView2_bookImage, Constant.BMOBFILE_ROOT+orders.getBookImage());

        return convertView;
    }
}
